package threading;

import com.sun.corba.se.spi.ior.ObjectKey;

/**
 * @author 徐志荣
 * @date 2023/3/19 10:57
 */
public class ThreadDemo16 {
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t1 = new Thread(() -> {
                try {
                    System.out.println("wait开始");
                    synchronized (locker){
                        locker.wait();
                    }
                    System.out.println("wait结束");
                }catch (InterruptedException e){
                    e.printStackTrace();
                }
        });
        t1.start();
        Thread.sleep(1000);
        Thread t2 = new Thread(() ->{
            synchronized (locker){
                System.out.println("notify 开始");
                locker.notify();
                System.out.println("notify 结束");
            }
       });
         t2.start();
    }
}
